package main

import (
	"fmt"
	"strconv"
)

func main() {
	//字符串的反转
	var str1 string
	fmt.Println("请输入你的字符串")
	fmt.Scan(&str1)
	fmt.Println(str1)
	lens := len(str1)
	str2 := ""
	for i := lens - 1; i >= 0; i-- {
		str2 = str2 + string(str1[i])

	}
	//fmt.Println(str2)
	//字符串的压缩
	var s string
	fmt.Scan(&s)

	count := 1
	result := ""
	for i := 0; i < len(s); i++ {
		if i+1 < len(s) && s[i] == s[i+1] {
			count++
		} else {
			result += string(s[i]) + strconv.Itoa(count)
			count = 1
		}
	}
	fmt.Println("压缩后的代码", result)
}
